package com.itheima.Interface3Demo;

public class ClassDateinter1 implements ClassStudents {
    Student[] students;
    public ClassDateinter1(Student[] students) {
        this.students = students;
    }
    @Override
    public void printAllStudents() {
        System.out.println("打印所有学生信息");
        System.out.println("姓名\t性别\t分数");
        for (Student student : students) {
            System.out.println(student.getName() + "\t" + student.getGender() + "\t" + student.getScore());
        }
    }
    @Override
    public void printAverageGrade() {
        System.out.println("打印所有学生的平均成绩");
        double sum = 0;
        for (Student student : students) {
            sum += student.getScore();
        }
        double average = sum / students.length;
        System.out.println("平均成绩：" + average);
    }



}
